import { ResDataType } from "@/types/coutest";
import request from "@/utils/request";

/**
 * 查询文章列表
 * @returns
 */
export function getList() {
    return request.get<ResDataType<any>>(`/api/blog/list`);
}

// 参数接口
export interface PushActivityParams {
    blogTags?: {
        blogId?: string;
        id?: string;
        isDel?: string;
        tagId?: string;
    }[];
    content?: string;
    id?: string;
    imagrUrl?: string;
    isComment?: string;
    isDel?: string;
    isTop?: string;
    password?: string;
    pushTime?: string;
    status?: string;
    summary?: string;
    title?: string;
    viewCount?: number;
    webTags?: {
        createBy?: string;
        createTime?: string;
        id?: string;
        isDel?: string;
        name?: string;
        params?: Record<string, unknown>;
        remark?: string;
        updateBy?: string;
        updateTime?: string;
    }[];
}

// 响应接口
export interface PushActivityRes {}

/**
 * 发布文章
 * @param {object} params 发布文字DTO
 * @param {array} params.blogTags
 * @param {string} params.content 文章内容
 * @param {string} params.id
 * @param {string} params.imagrUrl 文章图片
 * @param {string} params.isComment 是否允许评论 默认允许
 * @param {string} params.isDel
 * @param {string} params.isTop 是否置顶 0置顶 1否
 * @param {string} params.password
 * @param {object} params.pushTime 发布时间
 * @param {string} params.status 状态
 * @param {string} params.summary 文章摘要
 * @param {string} params.title 文字标题
 * @param {number} params.viewCount 浏览量
 * @param {array} params.webTags 新增的标签
 * @returns
 */
export function pushActivity(params: PushActivityParams): Promise<PushActivityRes> {
    return request.post(`/api/blog/push/blog`, params);
}

/**
 * 查询所有的文字标签
 * @returns
 */
export function queryTagList(): Promise<ResDataType<any>> {
    return request.get(`/api/blog/tags`);
}

export type ArticleDetailsInfo = {
    id: string;
    title: string;
    imagrUrl: string;
    content: string;
    summary: string;
};
export function getArticleDetailsInfoAPI(id: string) {
    return request.get<ResDataType<ArticleDetailsInfo>>(`/api/blog/info/${id}`);
}
export interface MyBlogList {
    id: string;
    title: string;
    imagrUrl: string;
    summary: string;
    content: string;
}
/**
 * 获取发布文章信息
 * @returns
 */
export function getMyPostBlogAPI() {
    return request.get<ResDataType<MyBlogList[]>>(`/api/u-center/message/blog`);
}
